package com.walker.security.util;

import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@SuppressWarnings("deprecation")
public class MyPasswordEncoder implements PasswordEncoder {
	
	private final static String SALT = "2018";

	@Override
	public String encode(CharSequence rawPassword) {
		Md5PasswordEncoder encoder = new Md5PasswordEncoder();
		return encoder.encodePassword(rawPassword.toString(), SALT);
	}

	@Override
	public boolean matches(CharSequence rawPassword, String encodedPassword) {
		Md5PasswordEncoder encoder = new Md5PasswordEncoder();
		return encoder.isPasswordValid(encodedPassword, rawPassword.toString(), SALT);
	}


}
